package conceptmaniax.hotelapp.util.geo;

import java.util.ArrayList;
import java.util.List;

import android.content.Context;
import android.graphics.drawable.Drawable;
import android.widget.Toast;

import com.google.android.maps.ItemizedOverlay;
import com.google.android.maps.OverlayItem;

public class LocationItemizedOverlay extends ItemizedOverlay<OverlayItem> {

	private List<OverlayItem> mOverlays = new ArrayList<OverlayItem>(); // NOPMD by manos on 9/14/12 1:42 PM
	private Context context;

	public LocationItemizedOverlay(final Drawable defaultMarker, final Context context) {
		super(boundCenterBottom(defaultMarker));
		this.context = context;
	}

	public void addOverlay(final OverlayItem overlay) {
		mOverlays.add(overlay);
		populate();
	}

	@Override
	protected OverlayItem createItem(final int itemIdx) {
		return (OverlayItem)mOverlays.get(itemIdx);
	}

	@Override
	public int size() {
		return mOverlays.size();
	}

	@Override
	protected boolean onTap(final int itemIdx) {
		final OverlayItem overlayItem = (OverlayItem)mOverlays.get(itemIdx);
		Toast.makeText(context, overlayItem.getSnippet(), Toast.LENGTH_SHORT).show();
		return true;
	}

	public Context getContext() {
		return context;
	}
	public void setContext(final Context context) {
		this.context = context;
	}

	public List<OverlayItem> getmOverlays() {
		return mOverlays;
	}

	public void setmOverlays(final List<OverlayItem> mOverlays) {
		this.mOverlays = mOverlays;
	}
}
